import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;

public class Easel extends JFrame implements Runnable{
  private String fileName;
  private Kanvas kanvas;;
  private int initWidth;
  private int initHeight;
  private int menuWidth;

  public Easel(String fileName, int initWidth, int initHeight, int menuWidth){
    this.fileName = fileName;
    this.initWidth = initWidth;
    this.initHeight = initHeight;
    this.menuWidth = menuWidth;
  }

  public void run(){
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(initWidth + menuWidth, initHeight);
    this.setLayout(new BoxLayout(this.getContentPane(),BoxLayout.X_AXIS));

    
    Palette palette = new Palette(menuWidth);
    BufferedImage blankImage = this.getGraphicsConfiguration().createCompatibleImage(initWidth, initHeight);
    Graphics2D blankImageGraphics = blankImage.createGraphics();
    blankImageGraphics.setColor(Color.white);
    blankImageGraphics.drawRect(0,0,initWidth,initHeight);
    blankImageGraphics.fillRect(0,0,initWidth,initHeight);
    kanvas = new Kanvas(palette, blankImage);
    JScrollPane kanvasScroll = new JScrollPane(kanvas);
    kanvasScroll.setBackground(Color.black);
    this.add(palette);
    this.add(kanvasScroll);

    kanvas.setVisible(true);
    palette.setVisible(true);
    this.setVisible(true);

    Pen dPen = new DefaultPen();
    Pen sPen = new SunPen();
    palette.addPen(dPen);
    palette.addPen(sPen);
    

    kanvas.paint(kanvas.getGraphics());
  }
}
